use std::ops::Index;
///Index trait
struct Student {
    name: String,
    age: u8,
}

impl Index<&str> for Student{
    type Output = String;

    fn index(&self, index: &str) -> &Self::Output {
        &self.name
    }
}
#[test]
pub fn index_trait_demo(){
    let s = Student{name: String::from("hello"), age: 23};
    let x = &s["ab"];
    println!("{}", x);
}